package com.gxuwz.eschool.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import androidx.fragment.app.Fragment;

import com.gxuwz.eschool.R;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


public class MessageFragment extends Fragment {

    ListView listView;
    SimpleAdapter simpleAdapter;

    public MessageFragment() {
        // Required empty public constructor
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_message,container,false);
        listView = view.findViewById(R.id.message_list_mes);
        simpleAdapter = new SimpleAdapter(
                getActivity(),
                getData(),
                R.layout.message_mes_item,
                new String[]{"pic","title","money","time","category","mesMain"},
                new int[]{R.id.mes_pic,R.id.mes_title,R.id.mes_money,R.id.mes_time,R.id.mes_category,R.id.mes_main}
        );
        listView.setAdapter(simpleAdapter);

        return view;
    }


    private List<Map<String,Object>> getData() {
        String [] titles={"[支付中心]一卡通充值","[支付中心]一卡通充值","[支付中心]一卡通充值"};
        int [] images={R.drawable.ld_tix,R.drawable.ld_tix,R.drawable.ld_tix};
        String [] time={"10分钟前","1小时前","2024-4-22"};
        String [] category={"系统通知","系统通知","系统通知"};
        String [] money={"￥150元","￥10元","￥50元"};
        String [] mesMain={"农行支付，支付成功","农行支付，支付成功","农行支付，支付成功"};
        List<Map<String,Object>> list= new ArrayList<>();
        for(int i=0;i<3;i++){
            Map  map = new HashMap();
            map.put("title",titles[i]);
            map.put("pic",images[i]);
            map.put("time",time[i]);
            map.put("category",category[i]);
            map.put("money",money[i]);
            map.put("mesMain",mesMain[i]);
            list.add(map);
        }
        return list;
    }


}